import { defineStore } from "pinia";
import $fetch from "../utils/request";
export const mainStore = defineStore("main", {
    state: () => {
        return {
            showother: false,
            layerGisShow: true,
            gather: false,
            glzArrys: [],
            sfzArrys: [],
            fwqArrys: [],
            ljArrys: [],
            viewpoint: [
                {
                    id: "06-2",
                    label: "许信高速",
                    disabled: true,
                    type: 1401,
                    data: {
                        heading: 1.3758426858617359,
                        height: 3460973.0335546248,
                        lat: 4895960.167171101,
                        lon: -2161840.0837606722,
                        pitch: -1.2211889675423757,
                        roll: 0.0006016403811948123,
                    },
                },
                {
                    id: "06-1",
                    label: "淮固高速",
                    disabled: true,
                    type: 1401,
                    data: {
                        heading: 5.23763121580318,
                        height: 3382445.895384826,
                        lat: 4875942.383770538,
                        lon: -2330388.545578442,
                        pitch: -1.335678355924785,
                        roll: 0.00006348621159890655,
                    },
                },
            ],
            punctuation: {
                show: false,
                position: null,
                position3d: null,
                state: 0,
                type: null,
                title: null,
            },
            punctuationList: [],
            level: null,
            Tenders:[],
            TendersShow:{
                show:false
            },
            dataManage:false,
            editTag: false,
            tagEntity: null,
            SearchShow: false,
            imgIconList:[]
        };
    },
    getters: {},
    actions: {
        incrementLayer(show) {
            this.layerGisShow = show;
        },
        changeGather(show) {
            this.gather = show;
        },
        changePunctuation(name, data) {
            this.punctuation[name] = data;
        },
        changeGlzArrys(show) {
            this.glzArrys = show;
        },
        changeViewpoint() {
            $fetch("/viewPoint/list", {}, "post").then((red) => {
                if (red.code == 200) {
                    let data = []
                    red.data.forEach((elees) => {
                        data.push({
                            ...elees,
                            label: elees.name,
                            disabled: true,
                            type: 1401,
                        });
                    });
                    this.viewpoint = data;
                }
            });
        },
        changePunctuationList(data) {
            this.punctuationList.push(data);
        },
        changeLevel(data) {
            this.level = data;
        },
        changeTenders(data){
            this.Tenders.push(data)
        },
        changeTendersShow(name, data) {
            this.TendersShow[name] = data;
        },
        changeDataManage(show){
            this.dataManage = show;
        },
        changeEditTag(show){
            this.editTag = show;
        },
        changeTagEntity(data){
            this.tagEntity = data;
        },
        changeSearchShow(show){
            this.SearchShow = show;
        },
        changeImgIconList() {
            $fetch("/mapicon/list", {}, "post").then((red) => {
                if (red.code == 200) {
                    this.imgIconList = red.data
                }
            });
        },
    },
});
